﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SalesItems.aspx.cs" Inherits="SalesItems" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Sales Item Broswer</title>

    <script type="text/javascript">
        function CheckForErrors()
        {
            if('<%=ErrorMessage %>' != '')
                alert('<%=ErrorMessage %>');
        }
    </script>

    <link href="Resources/Styles/Default.css" rel="Stylesheet" type="text/css">
</head>
<body onload="CheckForErrors()">
    <form id="form1" runat="server">
    <div>
        <div id="bookManagement">
            <fieldset>
                <legend>Books</legend>
                <table>
                    <tr>
                        <td>
                            Name
                        </td>
                        <td>
                            <asp:TextBox ID="txtBookName" runat="server" />
                            <asp:RequiredFieldValidator ControlToValidate="txtBookName" ID="Validator1" runat="server"
                                ValidationGroup="Books" Display="Dynamic" Text="*" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Price
                        </td>
                        <td>
                            <asp:TextBox ID="txtBookPrice" runat="server" />
                            <asp:RequiredFieldValidator ControlToValidate="txtBookPrice" ID="RequiredFieldValidator1"
                                runat="server" ValidationGroup="Books" Text="*" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Year
                        </td>
                        <td>
                            <asp:TextBox ID="txtBookYear" runat="server" />
                            <asp:RequiredFieldValidator ControlToValidate="txtBookYear" ID="RequiredFieldValidator2"
                                runat="server" ValidationGroup="Books" Display="Dynamic" Text="*" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Isbn
                        </td>
                        <td>
                            <asp:TextBox ID="txtBookISBN" runat="server" />
                            <asp:RequiredFieldValidator ControlToValidate="txtBookISBN" ID="RequiredFieldValidator3"
                                runat="server" ValidationGroup="Books" Display="Dynamic" Text="*" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            NumPages
                        </td>
                        <td>
                            <asp:TextBox ID="txtBookNumPages" runat="server" />
                            <asp:RequiredFieldValidator ControlToValidate="txtBookNumPages" ID="RequiredFieldValidator4"
                                runat="server" ValidationGroup="Books" Display="Dynamic" Text="*" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Author
                        </td>
                        <td>
                            <asp:TextBox ID="txtBookAuthor" runat="server" />
                            <asp:RequiredFieldValidator ControlToValidate="txtBookAuthor" ID="RequiredFieldValidator5"
                                runat="server" ValidationGroup="Books" Display="Dynamic" Text="*" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Courses
                        </td>
                        <td>
                            <asp:ListBox ID="lstBookCourses" runat="server" DataTextField="CourseNameAndNumber"
                                DataValueField="CourseID" SelectionMode="Multiple" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:Button ID="btnInsertBook" Text="Add" runat="server" OnClick="btnInsertBook_Click"
                                ValidationGroup="Books" />
                        </td>
                    </tr>
                </table>
                <asp:DataList ID="dlBooks" runat="server" RepeatColumns="1" RepeatLayout="Flow" OnItemDataBound="dlBooks_ItemDataBound">
                    <ItemTemplate>
                        <div id="dataRow">
                            <%#DataBinder.Eval(Container.DataItem,"Name") %>
                            $<%#DataBinder.Eval(Container.DataItem,"Price") %>
                            <%#DataBinder.Eval(Container.DataItem,"Year") %>
                            <%#DataBinder.Eval(Container.DataItem,"Isbn") %>
                            <%#DataBinder.Eval(Container.DataItem,"NumPages") %>
                            <%#DataBinder.Eval(Container.DataItem,"Author") %>
                            <%#DataBinder.Eval(Container.DataItem,"PostDate") %>
                            <%#DataBinder.Eval(Container.DataItem,"User.UserName") %>
                            <div id="innerDataRow">
                                <asp:Repeater ID="rptCourses" runat="server">
                                    <ItemTemplate>
                                        <%#DataBinder.Eval(Container.DataItem,"CourseNameAndNumber") %>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </div>
                        </div>
                    </ItemTemplate>
                </asp:DataList>
            </fieldset>
        </div>
        <div id="mediaManagement">
            <fieldset>
                <legend>Media</legend>
                <table>
                    <tr>
                        <td>
                            Name
                        </td>
                        <td>
                            <asp:TextBox ID="txtMediaName" runat="server" />
                            <asp:RequiredFieldValidator ControlToValidate="txtMediaName" ID="RequiredFieldValidator6"
                                runat="server" ValidationGroup="Media" Display="Dynamic" Text="*" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Price
                        </td>
                        <td>
                            <asp:TextBox ID="txtMediaPrice" runat="server" />
                            <asp:RequiredFieldValidator ControlToValidate="txtMediaPrice" ID="RequiredFieldValidator7"
                                runat="server" ValidationGroup="Media" Text="*" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Year
                        </td>
                        <td>
                            <asp:TextBox ID="txtMediaYear" runat="server" />
                            <asp:RequiredFieldValidator ControlToValidate="txtMediaYear" ID="RequiredFieldValidator8"
                                runat="server" ValidationGroup="Media" Display="Dynamic" Text="*" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Media Type
                        </td>
                        <td>
                            <asp:DropDownList ID="ddMediaTypes" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Courses
                        </td>
                        <td>
                            <asp:ListBox ID="lstMediaCourses" runat="server" DataTextField="CourseNameAndNumber"
                                DataValueField="CourseID" SelectionMode="Multiple" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:Button ID="btnAddMedia" Text="Add" runat="server" ValidationGroup="Media" OnClick="btnAddMedia_Click" />
                        </td>
                    </tr>
                </table>
                <asp:DataList ID="dlMedia" OnItemDataBound="dlBooks_ItemDataBound" runat="server" RepeatColumns="1" RepeatLayout="Flow">
                    <ItemTemplate>
                        <div id="dataRow">
                            <%#DataBinder.Eval(Container.DataItem,"Name") %>
                            $<%#DataBinder.Eval(Container.DataItem,"Price") %>
                            <%#DataBinder.Eval(Container.DataItem,"Year") %>
                            <%#DataBinder.Eval(Container.DataItem,"MediaType") %>
                            <div id="innerDataRow">
                                <asp:Repeater ID="rptCourses" runat="server">
                                    <ItemTemplate>
                                        <%#DataBinder.Eval(Container.DataItem,"CourseNameAndNumber") %>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </div>
                        </div>
                    </ItemTemplate>
                </asp:DataList>
            </fieldset>
        </div>
        <div id="courseManagement">
            <fieldset>
                <legend>Courses</legend>Course Name / Number
                <asp:TextBox ID="txtCourseNameAndNumber" runat="server" /><asp:RequiredFieldValidator ControlToValidate="txtCourseNameAndNumber" ID="RequiredFieldValidator9"
                                runat="server" ValidationGroup="Course" Display="Dynamic" Text="*" />
                <asp:Button ID="btnAddCourse" runat="server" ValidationGroup="Course" Text="Add" OnClick="btnAddCourse_Click" />
                <asp:DataList ID="dlCourses" runat="server" RepeatColumns="1" RepeatLayout="Flow">
                    <HeaderTemplate>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <div id="dataRow">
                            <%#DataBinder.Eval(Container.DataItem,"CourseNameAndNumber") %>
                        </div>
                    </ItemTemplate>
                </asp:DataList>
            </fieldset>
        </div>
    </div>
    </form>
</body>
</html>